const express = require("express");
// 导入joi
const expressJoi = require("@escook/express-joi");
// 使用express路由
const userInfoRouter = express.Router();
// 导入路由处理模块
const userInfoController = require("../Controller/userInfo");
// 导入验证规则
const {
  name_limit,
  email_limit,
  password_limit,
  loginPassword_limit,
} = require("../utils/limit/user");

// 上传头像
userInfoRouter.post("/uploadAvatar", userInfoController.uploadAvatar);
// 绑定头像
userInfoRouter.post("/bingAccount", userInfoController.bingAccount);
// 修改密码
userInfoRouter.post(
  "/updatePassword",
  expressJoi(password_limit),
  userInfoController.updatePassword
);
// 获取用户信息
userInfoRouter.get("/getUserInfo", userInfoController.getUserInfo);
// 修改姓名
userInfoRouter.post(
  "/updateName",
  expressJoi(name_limit),
  userInfoController.updateName
);
// 修改性别
userInfoRouter.post("/updateSex", userInfoController.updateSex);
// 修改邮箱
userInfoRouter.post(
  "/updateEmail",
  expressJoi(email_limit),
  userInfoController.updateEmail
);
userInfoRouter.post("/verify", userInfoController.verifyAccountAndEmail);
userInfoRouter.post(
  "/updatePasswordLogin",
  expressJoi(loginPassword_limit),
  userInfoController.updatePasswordLogin
);
module.exports = userInfoRouter;
